<template>
  <div class="js-basics">
    <header class="js-header">JS基础练习</header>
    <main class="js-main">
      <ul class="js-nav">
        <li
          v-for="item in jsNavList"
          :key="item.title"
          class="nav-item"
          :class="item.title === isActive ? 'nav-active' : ''"
          @click="onChangeNav(item)"
        >
          {{ item.title }}
        </li>
      </ul>
      <article class="js-artical">
        <h3 class="now-item-title">{{ nowItem.title }}</h3>
        <div class="now-item-content" v-html="nowItem.content"></div>
      </article>
    </main>
  </div>
</template>
<script setup>
import jsNavList from "./jsUntils/navUntil.js";
import { ref } from "vue";

let nowItem = ref(jsNavList[0]);
let isActive = ref(jsNavList[0].title);
function onChangeNav(item) {
  isActive.value = item.title;
  nowItem.value = item;
}
</script>
<style lang="scss" scoped>
@import "../../../style/common.scss";
.js-basics {
  display: flex;
  flex-direction: column;

  .js-header {
    width: 100%;
    height: 60px;
    font-size: 28px;
    text-align: center;
    line-height: 60px;
    border-bottom: 1px solid $hover-color;
  }

  .js-main {
    width: 100%;
    display: flex;
    padding: 16px;

    .js-nav {
      min-width: 120px;
      margin-right: 24px;
      height: auto;
      .nav-item {
        width: 100%;
        height: 38px;
        line-height: 38px;
        padding-left: 12px;
        padding-right: 12px;
        border: 1px solid $main-color;
        border-bottom: none;
        cursor: pointer;
        &:hover {
          background-color: $main-color;
          color: $hover-color;
        }
        &:last-child {
          border-bottom: 1px solid $main-color;
        }
      }
      .nav-active {
        background-color: $main-color;
        color: $hover-color;
      }
    }

    .js-artical {
      flex: 1;

      .now-item-title {
        font-weight: 600;
        font-size: 26px;
        text-align: center;
        margin-bottom: 24px;

        .h3-content {
          font-weight: 900;
          font-size: 20px;
        }
      }
    }
  }
}
</style>
